package com.booby.algorithm.bubble;

import com.booby.algorithm.utils.Utils;

/**
 * 功能描述: 冒泡排序，从小到大
 *
 * @author: lizt
 * @date: 2020/7/31 16:59
 **/

public class MinToMax {

    private static Integer[] arr = {5,7, 3, 2,6, 1, 9, 8,6, 7, 4};

    public static void main(String[] args) {
        sorted(arr);
    }

    public static void sorted(Integer[] arr){
        int len = arr.length;

        for (int k=0; k<len-1; k++) {
            int currentIndex = 0;
            int nextIndex = currentIndex + 1;

            for (int i = 0; i < len-k && nextIndex < len; i++) {
                if (arr[currentIndex] > arr[nextIndex]) {
                    Utils.swap(arr, currentIndex, nextIndex);
                }
                currentIndex++;
                nextIndex++;
            }
        }
//        Utils.print(arr);
    }
}
